<template>
  <div v-if="storage.getUserInfo()?.id">
    <div position-fixed bottom-100rpx style="width: 90%; left: 5%">
      <nut-button @click="visible = true" block plain>退出登录</nut-button>
    </div>
    <nut-dialog
      title="提示"
      content="是否要退出登录"
      v-model:visible="visible"
      @ok="singUp"
    />
  </div>
</template>

<script setup lang="ts">
import { logout } from '~/api/login'
import storage from '~/utils/storage'
const visible = ref<boolean>(false)

const singUp = async () => {
  storage.setAccessToken('')
  storage.setUserInfo({})

  // #ifndef MP-WEIXIN
  uni.redirectTo({
    url: '/pages/passport/login'
  })
  // #endif

  // #ifdef MP-WEIXIN
  uni.redirectTo({
    url: '/pages/passport/wechatMPLogin'
  })
  // #endif
  await logout()
}
</script>

<style scoped></style>
